import { ref, onMounted, onUnmounted, reactive } from "vue";

export const useMousePostion = () => {
  const x = ref(0),
    y = ref(0),
    // option = reactive({ x: 0, y: 0 }),
    update = e => {
      // option.x = e.pageX;
      // option.y = e.pageY;
      x.value = e.pageX;
      y.value = e.pageY;
    };
  onMounted(() => {
    window.addEventListener("mousemove", update);
  });
  onUnmounted(() => {
    window.removeEventListener("mousemove", update);
  });
  return { x, y };
};
